/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.account.Key.CalendarResourceBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.ZimbraLog;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.CalendarResource;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class CheckPasswordStrength
/*    */   extends AdminDocumentHandler
/*    */ {
/* 45 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/* 46 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 52 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException
/*    */   {
/* 57 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 58 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 60 */     String id = request.getAttribute("id");
/* 61 */     String password = request.getAttribute("password");
/*    */     
/* 63 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/* 64 */     if (account == null) {
/* 65 */       throw AccountServiceException.NO_SUCH_ACCOUNT(id);
/*    */     }
/* 67 */     if (account.isCalendarResource())
/*    */     {
/* 69 */       CalendarResource resource = prov.get(Key.CalendarResourceBy.id, id);
/* 70 */       checkCalendarResourceRight(zsc, resource, Rights.Admin.R_checkCalendarResourcePasswordStrength);
/*    */     } else {
/* 72 */       checkAccountRight(zsc, account, Rights.Admin.R_checkPasswordStrength);
/*    */     }
/*    */     
/* 75 */     prov.checkPasswordStrength(account, password);
/*    */     
/* 77 */     ZimbraLog.security.info(ZimbraLog.encodeAttrs(new String[] { "cmd", "CheckPasswordStrength", "name", account.getName() }));
/*    */     
/*    */ 
/* 80 */     Element response = zsc.createElement(AdminConstants.CHECK_PASSWORD_STRENGTH_RESPONSE);
/* 81 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 86 */     relatedRights.add(Rights.Admin.R_checkPasswordStrength);
/* 87 */     relatedRights.add(Rights.Admin.R_checkCalendarResourcePasswordStrength);
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/CheckPasswordStrength.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */